package com.twl.app.base.util;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.stereotype.Component;

/**
 * 根据bean名称获取bean
 * 
 * @author Val
 *
 */
@Component
public class BeanFactoryHolder implements BeanFactoryAware {

	private static BeanFactory beanFactory;

	@Override
	public void setBeanFactory(BeanFactory factory) throws BeansException {
		//System.out.println("************************************************************");
		beanFactory = factory;
	}

	public static Object getBean(String name){
		return beanFactory.getBean(name);
	}
	
}
